package org.suyafei.cotroller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.suyafei.manager.ProductManager;
import org.suyafei.service.ProductService;
import org.suyafei.utils.JsonData;
import org.suyafei.vo.ProductVO;

import java.util.List;

/**
 * @author 宿某人
 * @Date: 2022/02/05/8:15 下午
 * @Description:
 */
@RestController
@RequestMapping("api/product/v1")
public class ProductController {

    @Autowired
    private ProductService productService;


    @GetMapping("list")
    public JsonData list() {
        List<ProductVO> list = productService.list();
        return JsonData.buildSuccess(list);
    }

    @GetMapping("detail/{product_id}")
    public JsonData detail(@PathVariable("product_id") long productId) {
        ProductVO productVO = productService.findDetail(productId);
        return JsonData.buildSuccess(productVO);
    }
}
